package com.example.smartcity.ui.smartCity.fragment

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.smartcity.R
import com.example.smartcity.SmartCityApplication
import com.example.smartcity.databinding.FragmentSm2Binding
import com.example.smartcity.ui.smartCity.Adapter.Sm2RecyclerViewAdapter
import com.example.smartcity.ui.smartCity.model.Sm
import com.example.smartcity.ui.smartCity.model.Sm2

class SmFragment_2 : Fragment() {

    private lateinit var mBinding: FragmentSm2Binding
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        mBinding = FragmentSm2Binding.inflate(inflater, container, false)

        // 配置RecyclerView
        setAdapter()
        return mBinding.root
    }

    private fun setAdapter() {
        val array = ArrayList<Sm2>()
        val re = mBinding.Sm2RecyclerView

        for (i in 1..30){
            array.add(Sm2(
                SmartCityApplication.url + "/prod-api/profile/upload/image/2021/05/06/e614cb7f-63b0-4cda-bf47-db286ea1b074.png",
                "党员干部要终身学习 终身成长 $i",
                "简介: 党员干部要终身学习 终身成长 $i",
            "2023.2.15"
            ))
        }

        // 设置适配器
        LinearLayoutManager(context).apply {
            re.layoutManager = this
            Sm2RecyclerViewAdapter(array).apply {
                re.adapter = this
            }
        }
    }
}